#include <stdio.h>
#include <math.h>
#include <assert.h>


#ifndef NDEBUG
	#define DOUT( toprint ) printf( "# " toprint )
	#define DPUT( toput , x ) printf( "# " toput , x )
	#define DLN
#else
	#define DOUT
	#define DPUT
	#define DLN if(0)
#endif

int main()
{
	DOUT("=======================2007, 1 semester assignment, 2-B=======================\n");
	DOUT("==============================================================================\n");
	DOUT("Please enter the number of the prime number to output(less or equal to 10000):\n");
	DOUT("> ");

	long long int n = 0;    //n is long long because that'll lead to more reliable asserts
	int chk = scanf("%lld", &n);
	DLN assert(("You have entered a single number" , chk == 1));
	DLN assert(("N is actually less than 10000" , (n < 10000)));

	long int nPrimes[10001] = {2, 3, 5};//reliability boosts. Call them crutches if you want to
	long int lastprime = 3,	//number of block after last prime's block in nPrimes
	         curr = 1;		//lines 27-28 need re-doing if any upscaling is to take place

	while(! nPrimes[n]) {
		bool prime = 1;		//is the "curr" prime?
		++curr;

		for(int i = 0; i < lastprime; i++) {
			if(!(curr % nPrimes[i])) {
				prime = 0;
				break;
			}
		}

		if(prime) {
			nPrimes[lastprime] = curr;
			++lastprime;
		}
	}



	printf("%ld\n", nPrimes[n - 1]);
	DOUT("==============================================================================\n");
	DPUT("FILE: %s\n", __FILE__);
	DPUT("TIME OF COMPILATION: %s\n", __TIME__);

	return 0;
}
